package com.biwano.jsfextensions.converters;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Validate {

	private static final String EMAIL_PATTERN = 
		"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
		+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
	
	public static boolean eMail(String mail)
	{
		    //Set the email pattern string
	        Pattern p = Pattern.compile(EMAIL_PATTERN);
	        
	        //Match the given string with the pattern
	        Matcher m = p.matcher(mail);
	        
	        //Check whether match is found
	        return m.matches();
	}
}
